package com.sc.nft.controller;

import com.sc.nft.annotation.UserLogin;
import com.sc.nft.dto.IdRequest;
import com.sc.nft.entity.MallGrabCommoditiesFirstPageVO;
import com.sc.nft.entity.UserInfo;
import com.sc.nft.entity.dto.*;
import com.sc.nft.entity.vo.MemberMallActivityCouponsListVO;
import com.sc.nft.pool.UserPool;
import com.sc.nft.service.ActivityCouponsService;
import com.sc.nft.service.MallMemberEquityService;
import com.sc.nft.service.MallMemberService;
import com.sc.nft.sup.PageRequest;
import com.sc.nft.sup.PageResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * 商城会员控制器
 *
 * @Author：LiGen
 * @Package：com.sc.nft.controller
 * @Project：sc_metago
 * @name：MallMemberController
 * @Date：2024/4/1 15:00
 * @Filename：MallMemberController
 */
@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("/ipMall/member")
@Api(tags ="商城会员控制器")
public class MallMemberController {

    private final MallMemberService mallMemberService;
    private final MallMemberEquityService mallMemberEquityService;
    private final ActivityCouponsService activityCouponsService;

    @ApiOperation(value = "用户商城会员专区", notes = "用户商城会员专区", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @PostMapping(value = "/page", produces = MediaType.APPLICATION_JSON_VALUE)
    @UserLogin
    public PageResult<MallMemberPageDTO> geMallMemberPageDTO(@RequestBody PageRequest pageRequest) {
        return PageResult.success(mallMemberService.getMallMemberPageDTO(UserPool.getUser(),pageRequest.getPageNo(),pageRequest.getPageSize()));
    }

    @ApiOperation(value = "商品优先抢列表", notes = "商品优先抢列表", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @PostMapping(value = "/commoditiesFirst/page", produces = MediaType.APPLICATION_JSON_VALUE)
    @UserLogin
    public PageResult<MallGrabCommoditiesFirstPageDTO> getMallGrabCommoditiesFirstPageDTO(@Valid @RequestBody MallGrabCommoditiesFirstPageVO mallGrabCommoditiesFirstPageVO) {
        return PageResult.success(mallMemberEquityService.getMallGrabCommoditiesFirstPageDTO(mallGrabCommoditiesFirstPageVO.getMemberId(),mallGrabCommoditiesFirstPageVO.getPageNo(),mallGrabCommoditiesFirstPageVO.getPageSize()));
    }

    @ApiOperation(value = "优惠券活动列表", notes = "优惠券活动列表", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @PostMapping(value = "/activity/coupons/page", produces = MediaType.APPLICATION_JSON_VALUE)
    @UserLogin
    public PageResult<ActivityCouponsDTO> activityCouponsPage(@RequestBody MemberMallActivityCouponsListVO memberMallActivityCouponsListVO) {
        return PageResult.success(activityCouponsService.getMallMemberActivityCouponsDTOPage(memberMallActivityCouponsListVO.getPageNo(), memberMallActivityCouponsListVO.getPageSize(),
                UserPool.getUser(),memberMallActivityCouponsListVO.getMemberId(),memberMallActivityCouponsListVO.getMemberEquityTemplateId()));
    }
}
